package com.sxt.a02;

import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @author songjun
 */
public class CircleTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入圆的半径r:");
        double r = scanner.nextDouble();
        CircleTest circleTest = new CircleTest();
        System.out.println("圆的周长C=" + circleTest.getCirclePerimeter(r));
        System.out.println("圆的面积S=" + circleTest.getCircleArea(r));

    }

    /**
     * 根据半径求周长
     *
     * @param r
     * @return
     */
    public double getCirclePerimeter(double r) {
        double v = BigDecimal.valueOf(r).multiply(BigDecimal.valueOf(2))
                .multiply(BigDecimal.valueOf(3.14)).doubleValue();
        return v;
    }

    /**
     * 根据半径求面积
     *
     * @param r
     * @return
     */
    public double getCircleArea(double r) {
        return 3.14 * r * r;
    }
}
